//用看病来举栗子
function Patient(name,code){
    this.name=name;
    this.code=code;
}

function Queue(){
    this.dataStore=[];
    this.enqueue=enqueue;
    this.dequeue=dequeue;
    this.front=front;
    this.back=back;
    this.toString=toString;
    this.empty=empty;
}

//入队
function enqueue(ele){
    this.dataStore.push(ele);
}


//读取队首和队尾
function front(){
    return this.dataStore[0];
}

function back(){
    return this.dataStore[this.dataStore.length-1];
}


//判断队列是否为空
function empty(){
    if(this.dataStore.length===0){
        return true;
    }else{
        return false;
    }
}
//重新定义出队，因为上面定义了优先级的编码code
function dequeue(){
    var priority=this.dataStore[0].code;
    for(var i=0;i<this.dataStore.length;i++){
        if(this.dataStore[i].code<priority){
            priority=i;
        }
    }
    return this.dataStore.splice(priority,1);
}

function toString(){
    var reStr="";
    for(var i=0;i<this.dataStore.length;i++){
        reStr+=this.dataStore[i].name+" code:"+this.dataStore[i].code+"\n";
    }
    return reStr;
}